//
//  HPAccountLimitViewController.m
//  HPZZTong
//
//  Created by Handpay on 14-3-28.
//  Copyright (c) 2014年 Handpay. All rights reserved.
//

#import "HPAccountLimitViewController.h"
#import "LimitInfoData.h"

@interface HPAccountLimitViewController ()
@property(nonatomic, retain)NSArray* desArray;
@property(nonatomic, retain)NSArray* valueArray;
@end

@implementation HPAccountLimitViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.desArray = @[@"每日累计交易额度", @"每月累计交易额度", @"磁条每日累计交易额度",  @"磁条每月累计交易额度", @"单笔借记卡磁条交易限额", @"单笔信用卡磁条交易限额",@"单笔借记卡IC交易限额",@"单笔信用卡IC交易限额"];
        
        LimitInfoData* limitInfo = ZZT_CLIENG.accountInfo.cardTranferLimitInfo;
        
        NSString* dayTotalLimit = [limitInfo.dayLimit isEqualToString:@"-1"] ? @"无" : [Utility getFormatMoneyAndSymbol:limitInfo.dayLimit];
        
        NSString* monthTotalLimit = [limitInfo.monthLimit isEqualToString:@"-1"] ? @"无" : [Utility getFormatMoneyAndSymbol:limitInfo.monthLimit];
        
        NSString* dayMagLimit = [limitInfo.dayMagLimit isEqualToString:@"-1"] ? @"无" : [Utility getFormatMoneyAndSymbol:limitInfo.dayMagLimit];
        
        NSString* monthMagLimit = [limitInfo.monthMagLimit isEqualToString:@"-1"] ? @"无" : [Utility getFormatMoneyAndSymbol:limitInfo.monthMagLimit];
        
        NSString* debitCardLimit = [limitInfo.debitCardLimit isEqualToString:@"-1"] ? @"无" : [Utility getFormatMoneyAndSymbol:limitInfo.debitCardLimit];
        
        NSString* creditCardLimit = [limitInfo.creditCardLimit isEqualToString:@"-1"] ? @"无" : [Utility getFormatMoneyAndSymbol:limitInfo.creditCardLimit];
        
        NSString* icDebitCardLimit = [limitInfo.icDebitCardLimit isEqualToString:@"-1"] ? @"无" : [Utility getFormatMoneyAndSymbol:limitInfo.icDebitCardLimit];
        
        NSString* icCreditCardLimit = [limitInfo.icCreditCardLimit isEqualToString:@"-1"] ? @"无" : [Utility getFormatMoneyAndSymbol:limitInfo.icCreditCardLimit];
        
        
        self.valueArray = @[dayTotalLimit,monthTotalLimit,dayMagLimit,monthMagLimit,debitCardLimit,creditCardLimit,icDebitCardLimit,icCreditCardLimit];
    }
    return self;
}

- (void)viewDidLoad
{
    self.title = @"收款限额";
    [super viewDidLoad];
    
    self.limitTableView.dataSource = self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.valueArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    UILabel* desLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 150, 44)];
    desLabel.textColor = kNormalFontColor;
    desLabel.font = [UIFont systemFontOfSize:13.];
    desLabel.text = [self.desArray objectAtIndex:indexPath.row];
    [cell addSubview:desLabel];    
    [desLabel release];
    
    if (self.valueArray.count > 0) {
        UILabel* valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(160, 0, 150, 44)];
        valueLabel.textColor = [UIColor blackColor];
        valueLabel.font = [UIFont systemFontOfSize:16];
        valueLabel.text = [self.valueArray objectAtIndex:indexPath.row];
        valueLabel.textAlignment = NSTextAlignmentRight;
        [cell addSubview:valueLabel];
        [valueLabel release];
    }
    
    return [cell autorelease];
}

- (void)dealloc {
    self.desArray = nil;
    self.valueArray = nil;
    
    [_limitTableView release];
    [super dealloc];
}

- (void)viewDidUnload {
    [self setLimitTableView:nil];
    [super viewDidUnload];
}
@end
